ruby strings iteration problem solution